<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class User_model extends MY_Model 
{
    public $table = 'users';
    public $primary = 'user_id';
    
 /*   
    // Assign Secondary Queries to Object Attributes
    public function get_all_product_info($product_id)
    {
        $product = $this->find($product_id);
        $product->price_breaks = $this->get_product_price_breaks($product_id);
      
        return $product;
        
        // We’ll also remove a couple lines of assigning the results from the model to the $view_data variable.
        // $view_data['product'] = $this->product_model->get_all_product_info($product_id);
    }
    
    function getRandomProducts($limit)
    {
        $data = array();
        $temp = array();
        if ($limit == 0){
            $limit=3;
        }
        $Q = $this->db->get(‘products’);
        $temp = $Q->result_array();
        shuffle($temp);
        if (count($temp)){
            for ($i=1;$i <= $limit;$i++){
                $data[] = array_shift($temp);
            }
        }
        $Q->free_result();
        return $data;
    }

/*
    function batchUpdate(){
        if (count($this- > input- > post(‘p_id’))){
        $data = array(‘category_id’ = > $this- > input- > post(‘category_id’),
        ‘grouping’ = > $this- > input- > post(‘grouping’)
        );
        $idlist = implode(“,”,array_values($this- > input- > post(‘p_id’)));
        $where = “id in ($idlist)”;
        $this- > db- > where($where);
        $this- > db- > update(‘products’,$data);
        $this- > session- > set_flashdata(‘message’, ‘Products updated’);
        }else{
        $this- > session- > set_flashdata(‘message’, ‘Nothing to update!’);
        }
    }
*/
}